log using "Wang and Dickson 2021 PSRM results",replace name(WangDickson2021PSRM)

********************************************************************************
**  Replication for
**
**  How Corruption Investigations Undermine Regime Support: Evidence from China
**  Political Science Research and Methods
**  Yuhua Wang (yuhuawang@fas.harvard.edu)
**  Bruce Dickson (bdickson@gwu.edu)
**
**  Original Do-File Created on October 12, 2016
**  This Version Created on February 9, 2021
**
**  Stata 16.1
********************************************************************************

clear
estimates clear 
set more off


cd "~/Dropbox/China anti-corruption and public support/journal submission/PSRM/final submission/replication/"

* install if you have not yet
* ssc install interflex
* ssc install boottest

********************************************************************************
*Tables and Figures in the Main Text of the Paper*
********************************************************************************

********************************************
*Table 1: OLS Estimates of the Effects of Corruption Investigations on Regime Support*
********************************************

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731
*Bootstrapping produces different standard errors everytime, so I set a seed number to obtain consistent results.

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount post2012 provincecount
estimates store model1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount post2012 i.new_pid
estimates store model2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount post2012 `demographics' i.new_pid
estimates store model3
estadd ysumm

esttab model1 model2 model3 using table1.csv, replace ///
    keep(post2012_provincecount) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Year 2014 = post2012" "N of Corruption Investigations = provincecount" "Demographic Controls = male" "Province FE = *new_pid*")


********************************************
*Table 2: OLS Estimates of the Effects of Corruption Investigations on Beliefs in Officials’ Integrity*
********************************************
	
use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi:reg officialhonest post2012_provincecount  post2012 provincecount
estimates store updatemodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi:reg officialhonest post2012_provincecount  post2012 i.new_pid
estimates store updatemodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi:reg officialhonest post2012_provincecount  post2012 `demographics' i.new_pid
estimates store updatemodel3
estadd ysumm

esttab updatemodel1 updatemodel2 updatemodel3 using table2.csv, replace ///
    keep(post2012_provincecount) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Year 2014 = post2012" "N of Corruption Investigations = provincecount" "Demographic Controls = male" "Province FE = *new_pid*")


********************************************
*Figure 1: Marginal Effect of Corruption Investigations at Different Levels of Prior Beliefs in Officials’ Integrity*
********************************************

use "WandDicksonPSRMMainData.dta", clear
	
interflex supportcentralparty post2012_provincecount priorofficialhonest _Iprovincei_120000-_Iprovincei_630000 male age eduyear urban han partymember, cl(provinceid) cut(2.4 2.7)  ylabel(Support for Central Party) dlabel(Corruption Investigations) xlabel(Prior Beliefs in Officials' Integrity) sav(figure1.gph)

*NOTE: Hainmueller, Mummolo, and Xu (2019) argues that a linear interaction effect often produces excessive extrapolation and suggest a more flexible estimation strategy based on binned estimates. We hence only show the binned estimates and manually remove the linear extrapolation in the graph. This is done by clicking the "Graph Editor" in the Stata graph window. You can also change the aethetics of the graph. 


********************************************************************************
*Tables and Figures in the Online Appendix*
********************************************************************************

*********************************************
*Section I. Basic Information*
*********************************************

********************************************
*Table A1.1: Corruption Investigations by Province (January 2011 – July 2014)*
********************************************

use "provincial investigations.dta", clear

list provincename_eng pop2012 provincecount provinceweightedcount provinceflycount provincetigercount provincecountpermillion

************************************
*Table A1.2: Summary Statistics*
************************************

use "WandDicksonPSRMMainData.dta", clear

global y "trustcenter trustcentralparty supportcenter supportcentralparty trustcenter_dummyrev trustcentralparty_dummyrev supportcenter_dummyrev supportcentralparty_dummyrev trustcity trustcityparty supportcity supportcityparty regimesupport_alpha"
global center "n_central_provwork post2012_n_central_provwork n_central_provwork_w post2012_n_central_provwork_w n_central_provhometown post2012_n_central_provhometown n_central_provhometown_w post2012_n_central_provhome_w"
global x "post2012 provincecount provinceweightedcount provincetigercount provinceflycount provincecountpermillion provincecount_treat provincecount_timediscount"
global local "prefecturecount countycount"
global individual "male age eduyear urban han partymember fearcenter fearcenterresponse pcfamilyincome_log"
global corruptionperception "officialhonest priorofficialhonest"
global media "socialmedia socialmedia_pro"
estpost sum  $y $center $x $local $individual $corruptionperception $media

esttab using table_a_1_2.csv, cell((count(label(N)) ///
	mean(fmt(3) label(Mean)) sd(fmt(3) label(Standard Deviation)) min(fmt(3) label(Min.)) max(fmt(3) label(Max.)))) ///
	plain noobs label nomtitle nonumber replace

	
************************************
*Table A1.3: Comparing the 2010 and 2014 Samples (t-Tests)*
************************************	

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember pcfamilyincome_log"
local ymissing "trustcenter_missing trustcentralparty_missing supportcenter_missing supportcentralparty_missing"

forvalues i=1(1)25 { 
	estpost ttest `demographics' `ymissing' if provincesequence==`i', by(post2012) quietly
     esttab ., star( * 0.05 ** 0.01) not wide nonumber
}  

	
************************************
*Table A1.4: Testing Differential Composition Effect on Demographics (OLS Regression)*
************************************	

use "WandDicksonPSRMMainData.dta", clear

set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg male post2012_provincecount post2012 i.new_pid
estimates store compositionmodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg age post2012_provincecount post2012 i.new_pid
estimates store compositionmodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg eduyear post2012_provincecount post2012 i.new_pid
estimates store compositionmodel3
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg urban post2012_provincecount post2012 i.new_pid
estimates store compositionmodel4
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg han post2012_provincecount post2012 i.new_pid
estimates store compositionmodel5
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg partymember post2012_provincecount post2012 i.new_pid
estimates store compositionmodel6
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg pcfamilyincome_log post2012_provincecount post2012 i.new_pid
estimates store compositionmodel7
estadd ysumm

esttab compositionmodel1 compositionmodel2 compositionmodel3 compositionmodel4 compositionmodel5 compositionmodel6 compositionmodel7 using table_a_1_4.csv, ///
replace keep(post2012_provincecount post2012) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Province FE = *new_pid*")

	
	
************************************
*Table A1.5: The Effect of Central Corruption Investigations on Public Support (OLS Regressions)*
************************************	

use "WandDicksonPSRMMainData.dta",clear

global regimesupport "trustcenter trustcentralparty supportcenter supportcentralparty"

*Panel I: N of Corrupt Central Officials (Work)*

set seed 339487731

foreach x in regimesupport {
  eststo clear
  foreach y of varlist $`x' {
    quietly eststo, title(`y'): bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg `y' post2012_n_central_provwork post2012 i.new_pid
  }
  esttab using table_a_1_5_1.csv, cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01) stats(N N_clust r2, fmt(0 0 3) labels("Observations" "N of Clusters" "R2")) keep(post2012_n_central_provwork post2012) indicate("Province FE = *new_pid*") label replace
  eststo clear
  }

*Panel II: N of Corrupt Central Officials (Work)(Weighted)*

set seed 339487731

  foreach x in regimesupport {
  eststo clear
  foreach y of varlist $`x' {
    quietly eststo, title(`y'): bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg `y' post2012_n_central_provwork_w post2012 i.new_pid
  }
  esttab using table_a_1_5_2.csv, cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01) stats(N N_clust r2, fmt(0 0 3) labels("Observations" "N of Clusters" "R2")) keep(post2012_n_central_provwork_w post2012) indicate("Province FE = *new_pid*") label replace
  eststo clear
  }

*Panel III: N of Corrupt Central Officials (Hometown)*

set seed 339487731

  foreach x in regimesupport {
  eststo clear
  foreach y of varlist $`x' {
    quietly eststo, title(`y'): bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg `y' post2012_n_central_provhometown  post2012 i.new_pid
  }
  esttab using table_a_1_5_3.csv, cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01) stats(N N_clust r2, fmt(0 0 3) labels("Observations" "N of Clusters" "R2"))  keep(post2012_n_central_provhometown  post2012) indicate("Province FE = *new_pid*") label replace
  eststo clear
  }

*Panel IV: N of Corrupt Central Officials (Hometown)(Weighted)*

set seed 339487731

 foreach x in regimesupport {
  eststo clear
  foreach y of varlist $`x' {
    quietly eststo, title(`y'): bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg `y' post2012_n_central_provhome_w  post2012 i.new_pid
  }
  esttab using table_a_1_5_4.csv, cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01) stats(N N_clust r2, fmt(0 0 3) labels("Observations" "N of Clusters" "R2"))  keep(post2012_n_central_provhome_w  post2012) indicate("Province FE = *new_pid*") label replace
  eststo clear
  }

	
************************************
*Table A1.6: Placebo Tests Using Two Pre-Treatment Surveys and One Post-Treatment Survey (OLS Regressions)*
************************************	

use "individualpretrend.dta",clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi:reg trustcenter_std y2010_provincecount y2014_provincecount year2010 year2014 i.new_pid
estimates store testmodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi:reg trustcenter_std y2010_provincecount y2014_provincecount year2010 year2014 `demographics' i.new_pid
estimates store testmodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi:reg trustcentralparty_std y2010_provincecount y2014_provincecount year2010 year2014 i.new_pid
estimates store testmodel3
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi:reg trustcentralparty_std y2010_provincecount y2014_provincecount year2010 year2014 `demographics' i.new_pid
estimates store testmodel4
estadd ysumm

esttab testmodel1 testmodel2 testmodel3 testmodel4 using table_a_1_6.csv, replace ///
    keep(y2010_provincecount y2014_provincecount year2010 year2014) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(0 0 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *new_pid*")
		
	
************************************
*Figure A1.1: Correlates of Corruption Investigations*
************************************	

use "provincialpretrend.dta", clear

*Getting the correlation coefficients*

pwcorr provincecount trustcenter,sig
pwcorr provincecount trustcentralparty,sig
pwcorr provincecount supportcenter,sig
pwcorr provincecount supportcentralparty,sig
pwcorr provincecount pcgdp,sig
pwcorr provincecount gdpgrowth,sig
pwcorr provincecount corruption1,sig
pwcorr provincecount corruption2,sig
pwcorr provincecount corruption3,sig

*Making the scatter plots*

*(a)

twoway (scatter provincecount trustcenter, mcolor(black) saving(trustcenter, replace)) ///
(lfit provincecount trustcenter, lpattern(solid) lcolor(black) lwidth(medthick) ),  ///
title("(a)") legend(off) ytitle("Corruption Investigations (2011–2014)") xtitle("Average Trust in Central Government (2010)") ///
scheme(sj)  scale(0.8)  graphregion(fcolor(white)) text(390 7.5 "slope = -0.16, p=0.43", place(se) size(vlarge))

*(b)

twoway (scatter provincecount trustcentralparty, mcolor(black) saving(trustcentralparty, replace)) ///
(lfit provincecount trustcentralparty, lpattern(solid) lcolor(black) lwidth(medthick) ),  ///
title("(b)") legend(off) ytitle("Corruption Investigations (2011–2014)") xtitle("Average Trust in Central Party (2010)") ///
scheme(sj)  scale(0.8)  graphregion(fcolor(white)) text(390 7.7 "slope = -0.15, p=0.47", place(se) size(vlarge))

*(c)

twoway (scatter provincecount supportcenter, mcolor(black) saving(supportcenter, replace)) ///
(lfit provincecount supportcenter, lpattern(solid) lcolor(black) lwidth(medthick) ),  ///
title("(c)") legend(off) ytitle("Corruption Investigations (2011–2014)") xtitle("Average Support for Central Government (2010)") ///
scheme(sj)  scale(0.8)  graphregion(fcolor(white)) text(390 8 "slope = -0.16, p=0.45", place(se) size(vlarge))

*(d)

twoway (scatter provincecount supportcentralparty, mcolor(black) saving(supportcentralparty, replace)) ///
(lfit provincecount supportcentralparty, lpattern(solid) lcolor(black) lwidth(medthick) ),  ///
title("(d)") legend(off) ytitle("Corruption Investigations (2011–2014)") xtitle("Average Support for Central Party (2010)") ///
scheme(sj)  scale(0.8)  graphregion(fcolor(white)) text(390 8 "slope = -0.13, p=0.52", place(se) size(vlarge))

*(e)

twoway (scatter provincecount pcgdp, mcolor(black) saving(gdp, replace)) ///
(lfit provincecount pcgdp, lpattern(solid) lcolor(black) lwidth(medthick) ),  ///
title("(e)") legend(off) ytitle("Corruption Investigations (2011–2014)") xtitle("Per Capita GDP (2010)") ///
scheme(sj)  scale(0.8)  graphregion(fcolor(white)) text(460 48000 "slope = -0.10, p=0.65", place(se) size(vlarge))

*(f)

twoway (scatter provincecount gdpgrowth, mcolor(black) saving(gdpgrow, replace)) ///
(lfit provincecount gdpgrowth, lpattern(solid) lcolor(black) lwidth(medthick) ),  ///
title("(f)") legend(off) ytitle("Corruption Investigations (2011–2014)") xtitle("GDP Growth Rate (%) (2010)") ///
scheme(sj)  scale(0.8)  graphregion(fcolor(white)) text(450 14 "slope = -0.16, p=0.44", place(se) size(vlarge))

*(g)

twoway (scatter provincecount corruption1, mcolor(black) saving(corruption1, replace)) ///
(lfit provincecount corruption1, lpattern(solid) lcolor(black) lwidth(medthick) ),  ///
title("(g)") legend(off) ytitle("Corruption Investigations (2011–2014)") xtitle("Recovered Corrupt Funds Per Filed Case (log) (2003-2007)") ///
scheme(sj)  scale(0.8)  graphregion(fcolor(white)) text(450 3.2 "slope = -0.10, p=0.65", place(se) size(vlarge))

*(h)

twoway (scatter provincecount corruption2, mcolor(black) saving(corruption2, replace)) ///
(lfit provincecount corruption2, lpattern(solid) lcolor(black) lwidth(medthick) ),  ///
title("(h)") legend(off) ytitle("Corruption Investigations (2011–2014)") xtitle("Recovered Corrupt Funds Per Capita (log) (2003-2007)") ///
scheme(sj)  scale(0.8)  graphregion(fcolor(white)) text(450 1.8 "slope = -0.03, p=0.88", place(se) size(vlarge))

*(i)

twoway (scatter provincecount corruption3, mcolor(black) saving(corruption3, replace)) ///
(lfit provincecount corruption3, lpattern(solid) lcolor(black) lwidth(medthick) ),  ///
title("(i)") legend(off) ytitle("Corruption Investigations (2011–2014)") xtitle("Senior Cadres Disciplined Per 10,000 Public Employees (log) (2003-2007)") ///
scheme(sj)  scale(0.8)  graphregion(fcolor(white)) text(450 -1 "slope = -0.09, p=0.67", place(se) size(vlarge))


*Figure A1.1 (a)
graph combine trustcenter.gph trustcentralparty.gph supportcenter.gph supportcentralparty.gph, scheme(sj) col(2)  graphregion(fcolor(white))
graph export figurea1_1_a.pdf, as(pdf) replace

*Figure A1.1 (b)
graph combine gdp.gph gdpgrow.gph corruption1.gph corruption2.gph corruption3.gph, scheme(sj) col(2)  graphregion(fcolor(white))
graph export figurea1_1_b.pdf, as(pdf) replace


		
************************************************************************
*Section II. Benchmark Results*
************************************************************************


************************************
*Table A2.1: Difference-in-Differences Estimates of the Effects of Corruption Investigations on Public Support (Full OLS Results)*
************************************

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount post2012 provincecount
estimates store model1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount post2012 i.new_pid
estimates store model2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount post2012 `demographics' i.new_pid
estimates store model3
estadd ysumm
	
esttab model1 model2 model3 using table_a_2_1.csv, replace ///
    keep(post2012_provincecount post2012 provincecount male age eduyear urban han partymember) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Province FE = *new_pid*")



************************************
*Table A2.2: Difference-in-Differences Estimates of the Effects of Corruption Investigations at the Prefectural or County Level on Public Support (OLS Regressions)*
************************************

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
local provincefe "i.provinceid"
local prefecturefe "i.prefectureid"
local countyfe "i.countyid"

*Columns 1-4*

xi:reg trustcenter post2012_prefecturecount post2012 `demographics' `prefecturefe',cl(prefectureid)
estimates store prefmodel1
estadd ysumm

xi:reg trustcentralparty post2012_prefecturecount post2012 `demographics' `prefecturefe',cl(prefectureid)
estimates store prefmodel2
estadd ysumm

xi:reg supportcenter post2012_prefecturecount post2012 `demographics' `prefecturefe',cl(prefectureid)
estimates store prefmodel3
estadd ysumm

xi:reg supportcentralparty post2012_prefecturecount post2012 `demographics' `prefecturefe',cl(prefectureid)
estimates store prefmodel4
estadd ysumm

*Columns 5-8*

xi:reg trustcenter post2012_countycount post2012 `demographics' `countyfe',cl(countyid)
estimates store countymodel1
estadd ysumm

xi:reg trustcentralparty post2012_countycount post2012 `demographics' `countyfe',cl(countyid)
estimates store countymodel2
estadd ysumm

xi:reg supportcenter post2012_countycount post2012 `demographics' `countyfe',cl(countyid)
estimates store countymodel3
estadd ysumm

xi:reg supportcentralparty post2012_countycount post2012 `demographics' `countyfe',cl(countyid)
estimates store countymodel4
estadd ysumm

esttab prefmodel1 prefmodel2 prefmodel3 prefmodel4 countymodel1 countymodel2 countymodel3 countymodel4 using table_a_2_2.csv, replace ///
    keep(post2012_prefecturecount post2012 post2012_countycount) ///
	order(post2012_prefecturecount prefecturecount post2012_countycount countycount post2012) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Prefecture FE = *Iprefectur*" "County FE = *Icountyid*")
	
	

************************************
*Table A2.3 Difference-in-Differences Estimates of the Effects of Corruption Investigations at the Prefectural Level on Public Support for Prefectural Organizations (OLS Regressions)*
************************************

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
local prefecturefe "i.prefectureid"

xi:reg trustcity post2012_prefecturecount post2012 `demographics' `prefecturefe',cl(prefectureid)
estimates store citymodel1
estadd ysumm

xi:reg trustcityparty post2012_prefecturecount post2012 `demographics' `prefecturefe',cl(prefectureid)
estimates store citymodel2
estadd ysumm

xi:reg supportcity post2012_prefecturecount post2012 `demographics' `prefecturefe',cl(prefectureid)
estimates store citymodel3
estadd ysumm

xi:reg supportcityparty post2012_prefecturecount post2012 `demographics' `prefecturefe',cl(prefectureid)
estimates store citymodel4
estadd ysumm

esttab citymodel1 citymodel2 citymodel3 citymodel4 using table_a_2_3.csv, replace ///
    keep(post2012_prefecturecount post2012) ///
	order(post2012_prefecturecount post2012) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Prefecture FE = *Iprefectur*")
	
	
************************************************************************
*Section III. Robustness Checks*
************************************************************************

************************************
*Table A3.1: Using Alternative Dependent Variables (OLS Regressions)*
************************************

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcenter post2012_provincecount post2012 i.new_pid
estimates store dvmodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcenter post2012_provincecount post2012 `demographics' i.new_pid
estimates store dvmodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcentralparty post2012_provincecount post2012 i.new_pid
estimates store dvmodel3
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcentralparty post2012_provincecount post2012 `demographics' i.new_pid
estimates store dvmodel4
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcenter post2012_provincecount post2012 i.new_pid
estimates store dvmodel5
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcenter post2012_provincecount post2012 `demographics' i.new_pid
estimates store dvmodel6
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg regimesupport_alpha post2012_provincecount post2012 i.new_pid
estimates store dvmodel7
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg regimesupport_alpha post2012_provincecount post2012 `demographics' i.new_pid
estimates store dvmodel8
estadd ysumm

esttab dvmodel1 dvmodel2 dvmodel3 dvmodel4 dvmodel5 dvmodel6 dvmodel7 dvmodel8 using table_a_3_1.csv, replace ///
    keep(post2012_provincecount post2012) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *new_pid*")
	

************************************
*Table A3.2: Using Weighted Number of Corruption Investigations (OLS Regressions)*
************************************

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcenter post2012_provinceweightedcount post2012 `demographics' i.new_pid
estimates store weightedmodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcentralparty post2012_provinceweightedcount post2012 `demographics' i.new_pid
estimates store weightedmodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcenter post2012_provinceweightedcount post2012 `demographics' i.new_pid
estimates store weightedmodel3
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provinceweightedcount post2012 `demographics' i.new_pid
estimates store weightedmodel4
estadd ysumm

esttab weightedmodel1 weightedmodel2 weightedmodel3 weightedmodel4 using table_a_3_2.csv, replace ///
    keep(post2012_provinceweightedcount post2012) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *new_pid*")
	
************************************
*Table A3.3: Using Number of Tigers (OLS Regressions)*
************************************

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcenter post2012_provincetigercount post2012 `demographics' i.new_pid
estimates store tigermodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcentralparty post2012_provincetigercount post2012 `demographics' i.new_pid
estimates store tigermodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcenter post2012_provincetigercount post2012 `demographics' i.new_pid
estimates store tigermodel3
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincetigercount post2012 `demographics' i.new_pid
estimates store tigermodel4
estadd ysumm

esttab tigermodel1 tigermodel2 tigermodel3 tigermodel4 using table_a_3_3.csv, replace ///
    keep(post2012_provincetigercount post2012) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *new_pid*")
	
	
	
************************************
*Table A3.4: Using Number of Flies (OLS Regressions)*
************************************

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcenter post2012_provinceflycount post2012 `demographics' i.new_pid
estimates store flymodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcentralparty post2012_provinceflycount post2012 `demographics' i.new_pid
estimates store flymodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcenter post2012_provinceflycount post2012 `demographics' i.new_pid
estimates store flymodel3
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provinceflycount post2012 `demographics' i.new_pid
estimates store flymodel4
estadd ysumm

esttab flymodel1 flymodel2 flymodel3 flymodel4 using table_a_3_4.csv, replace ///
    keep(post2012_provinceflycount post2012) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *new_pid*")

************************************
*Table A3.5: Using Number of Corruption Investigations Per Million (OLS Regressions)*
************************************ 

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember "
set seed 12345678

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcenter post2012_provincecountpermillion post2012 `demographics' i.new_pid
estimates store popmodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcentralparty post2012_provincecountpermillion post2012 `demographics' i.new_pid
estimates store popmodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcenter post2012_provincecountpermillion post2012 `demographics' i.new_pid
estimates store popmodel3
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecountpermillion post2012 `demographics' i.new_pid
estimates store popmodel4
estadd ysumm

esttab popmodel1 popmodel2 popmodel3 popmodel4 using table_a_3_5.csv, replace ///
    keep(post2012_provincecountpermillion post2012) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *new_pid*")

	
************************************
*Table A3.6: Using Dichotomous Dependent Variables (OLS Regressions)*
************************************ 

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
local provincefe "i.provinceid"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcenter_dummyrev post2012_provincecount post2012 `demographics' i.new_pid
estimates store dummymodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcentralparty_dummyrev post2012_provincecount post2012 `demographics' i.new_pid
estimates store dummymodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcenter_dummyrev post2012_provincecount post2012 `demographics' i.new_pid
estimates store dummymodel3
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty_dummyrev post2012_provincecount post2012 `demographics' i.new_pid
estimates store dummymodel4
estadd ysumm

esttab dummymodel1 dummymodel2 dummymodel3 dummymodel4 using table_a_3_6.csv, replace ///
    keep(post2012_provincecount post2012) ///
	cells(b(star fmt(4)) se(fmt(4) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *new_pid*")

************************************
*Table A3.7: Did Corruption Investigations Change Political Fear (OLS Regressions)*
************************************ 

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg fearcenter post2012_provincecount post2012 i.new_pid
estimates store fear1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg fearcenter post2012_provincecount post2012 `demographics' i.new_pid
estimates store fear2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg fearcenterresponse post2012_provincecount post2012 i.new_pid
estimates store fear3
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg fearcenterresponse post2012_provincecount post2012 `demographics' i.new_pid
estimates store fear4
estadd ysumm

esttab fear1 fear2 fear3 fear4 using table_a_3_7.csv, replace ///
    keep(post2012_provincecount post2012) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *new_pid*")
	
************************************
*Table A3.8: Controlling for Political Fear (OLS Regressions)*
************************************ 

use "WandDicksonPSRMMainData.dta", clear

*Columns 1-4*

local demographics "male age eduyear urban han partymember fearcenter"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcenter post2012_provincecount post2012 `demographics' i.new_pid
estimates store fearmodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcentralparty post2012_provincecount post2012 `demographics' i.new_pid
estimates store fearmodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcenter post2012_provincecount post2012 `demographics' i.new_pid
estimates store fearmodel3
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount post2012 `demographics' i.new_pid
estimates store fearmodel4
estadd ysumm

*Columns 5-8*

local demographics "male age eduyear urban han partymember fearcenterresponse"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcenter post2012_provincecount post2012 `demographics' i.new_pid
estimates store fearmodel5
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcentralparty post2012_provincecount post2012 `demographics' i.new_pid
estimates store fearmodel6
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcenter post2012_provincecount post2012 `demographics' i.new_pid
estimates store fearmodel7
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount post2012 `demographics' i.new_pid
estimates store fearmodel8
estadd ysumm

esttab fearmodel1 fearmodel2 fearmodel3 fearmodel4 fearmodel5 fearmodel6 fearmodel7 fearmodel8 using table_a_3_8.csv, replace ///
    keep(post2012_provincecount post2012 fearcenter fearcenterresponse) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *new_pid*")
	
************************************
*Table A3.9: Controlling for Per Capita Family Income (OLS Regressions)*
************************************ 

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember pcfamilyincome_log"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcenter post2012_provincecount post2012 `demographics' i.new_pid
estimates store incomemodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcentralparty post2012_provincecount post2012 `demographics' i.new_pid
estimates store incomemodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcenter post2012_provincecount post2012 `demographics' i.new_pid
estimates store incomemodel3
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount post2012 `demographics' i.new_pid
estimates store incomemodel4
estadd ysumm

esttab incomemodel1 incomemodel2 incomemodel3 incomemodel4 using table_a_3_9.csv, replace ///
    keep(post2012_provincecount post2012) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Per Capita Family Income (log) = pcfamilyincome_log" "Province FE = *new_pid*")
	

************************************
*Table A3.10: Dropping New Migrants*
************************************ 

use  "WandDicksonPSRMMainData.dta", clear

preserve

*Dropping respondents who moved to the current city between 2011 and 2014*

drop if post2012==1 & a2ay<=4

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcenter post2012_provincecount post2012 `demographics' i.new_pid
estimates store residentmodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcentralparty post2012_provincecount post2012 `demographics' i.new_pid
estimates store residentmodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcenter post2012_provincecount post2012 `demographics' i.new_pid
estimates store residentmodel3
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount post2012 `demographics' i.new_pid
estimates store residentmodel4
estadd ysumm

esttab residentmodel1 residentmodel2 residentmodel3 residentmodel4 using table_a_3_10.csv, replace ///
    keep(post2012_provincecount post2012) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *new_pid*")

restore


************************************ 
*Table A3.11: Considering Survey Design Effects*
************************************ 

use "WandDicksonPSRMMainData.dta",clear

svyset [pweight=pweight], psu(psu) strata(strata)

local demographics "male age eduyear urban han partymember"
local provincefe "i.provinceid"

xi:svy:reg trustcenter post2012_provincecount post2012 `demographics' `provincefe'
estimates store svymodel1
estadd ysumm

xi:svy:reg trustcentralparty post2012_provincecount post2012 `demographics' `provincefe'
estimates store svymodel2
estadd ysumm

xi:svy:reg supportcenter post2012_provincecount post2012 `demographics' `provincefe'
estimates store svymodel3
estadd ysumm

xi:svy:reg supportcentralparty post2012_provincecount post2012 `demographics' `provincefe'
estimates store svymodel4
estadd ysumm

esttab svymodel1 svymodel2 svymodel3 svymodel4 using table_a_3_11.csv, replace ///
    keep(post2012_provincecount post2012) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_pop r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "Population Size" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *Iprovincei*")
	
svyset, clear
  


************************************ 
*Table A3.12: Using Multiple Imputation to Deal with Missing Data in the Dependent Variables*
************************************ 

use "WandDicksonPSRMMainData.dta", clear

mi set mlong

*Save it as a separate dataset to avoid messing up the original data*

save "WandDicksonPSRMMainDataForMI.dta", replace

mi register imputed trustcenter trustcentralparty supportcenter supportcentralparty

mi misstable summarize trustcenter trustcentralparty supportcenter supportcentralparty, all

mi xtset, clear

mi impute regress trustcenter male age eduyear urban han partymember, add(20) rseed(1114) force
mi impute regress trustcentralparty male age eduyear urban han partymember, add(20) rseed(1115) force
mi impute regress supportcenter male age eduyear urban han partymember, add(20) rseed(1116) force
mi impute regress supportcentralparty male age eduyear urban han partymember, add(20) rseed(1117) force

drop if trustcenter==. | trustcentralparty==. | supportcenter==. | supportcentralparty==.|  male==. | age==. | eduyear==. | urban==. | han==. | partymember==. | provincecount==.

*Results*

local demographics "male age eduyear urban han partymember"
local provincefe "i.provinceid"

xi: eststo: mi estimate, post:reg trustcenter post2012_provincecount post2012 `demographics' `provincefe', cl(provinceid)
estimates store mimodel1

xi: eststo:mi estimate, post:reg trustcentralparty post2012_provincecount post2012 `demographics' `provincefe', cl(provinceid)
estimates store mimodel2

xi: eststo:mi estimate, post:reg supportcenter post2012_provincecount post2012 `demographics' `provincefe', cl(provinceid)
estimates store mimodel3

xi: eststo:mi estimate, post:reg supportcentralparty post2012_provincecount post2012 `demographics' `provincefe', cl(provinceid)
estimates store mimodel4

esttab mimodel1 mimodel2 mimodel3 mimodel4 using table_a_3_12.csv, replace ///
    keep(post2012_provincecount post2012) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(N N_clust, fmt(0 0) labels("Observations" "N of Clusters")) ///
	indicate("Demographic Controls = male" "Province FE = *Iprovincei*")



************************************
*Table A3.13: Controlling for Spatial Lag*
************************************

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcenter post2012_provincecount post2012_splag post2012 `demographics' i.new_pid
estimates store splagmodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg trustcentralparty post2012_provincecount post2012_splag post2012 `demographics' i.new_pid
estimates store splagmodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcenter post2012_provincecount post2012_splag post2012 `demographics' i.new_pid
estimates store splagmodel3
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount post2012_splag post2012 `demographics' i.new_pid
estimates store splagmodel4
estadd ysumm

esttab splagmodel1 splagmodel2 splagmodel3 splagmodel4 using table_a_3_13.csv, replace ///
    keep(post2012_provincecount post2012_splag post2012) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *new_pid*")
	
	

********
*Table A3.14: Using Selection on Observables to Assess the Bias from Unobservables*
********

use "WandDicksonPSRMMainData.dta", clear

*trust central gov*

local demographics "male age eduyear urban han partymember"
local provincefe "i.provinceid"

*Full 1*
xi:reg trustcenter post2012_provincecount post2012 provincecount `provincefe', cl(provinceid)
gen beta1=_b[post2012_provincecount]
* Restricted #1
xi:reg trustcenter post2012_provincecount post2012 provincecount, cl(provinceid)
gen beta2=_b[post2012_provincecount]
* Row 1 Column 1
gen diff1_2=beta1/(beta2-beta1)
drop beta*
sum diff*
drop diff*


local demographics "male age eduyear urban han partymember"
local provincefe "i.provinceid"

*Full 2*
xi:reg trustcenter post2012_provincecount post2012 provincecount `demographics' `provincefe', cl(provinceid)
gen beta3=_b[post2012_provincecount]
* Restricted #2
xi:reg trustcenter post2012_provincecount post2012 provincecount `provincefe', cl(provinceid)
gen beta4=_b[post2012_provincecount]
* Row 2 Column 1
gen diff3_4=beta3/(beta4-beta3)
drop beta*
sum diff*
drop diff*


**trust central party**

local demographics "male age eduyear urban han partymember"
local provincefe "i.provinceid"

*Full 3*
xi:reg trustcentralparty post2012_provincecount post2012 provincecount `provincefe', cl(provinceid)
gen beta1=_b[post2012_provincecount]
* Restricted #3
xi:reg trustcentralparty post2012_provincecount post2012 provincecount, cl(provinceid)
gen beta2=_b[post2012_provincecount]
* Row 1 Column 2
gen diff1_2=beta1/(beta2-beta1)
drop beta*
sum diff*
drop diff*


local demographics "male age eduyear urban han partymember"
local provincefe "i.provinceid"

*Full 4*
xi:reg trustcentralparty post2012_provincecount post2012 provincecount `demographics' `provincefe', cl(provinceid)
gen beta3=_b[post2012_provincecount]
* Restricted #4
xi:reg trustcentralparty post2012_provincecount post2012 provincecount `provincefe', cl(provinceid)
gen beta4=_b[post2012_provincecount]
* Row 2 Column 2
gen diff3_4=beta3/(beta4-beta3)
drop beta*
sum diff*
drop diff*


*support central gov*

local demographics "male age eduyear urban han partymember"
local provincefe "i.provinceid"

*Full 5*
xi:reg supportcenter post2012_provincecount post2012 provincecount `provincefe', cl(provinceid)
gen beta1=_b[post2012_provincecount]
* Restricted #5
xi:reg supportcenter post2012_provincecount post2012 provincecount, cl(provinceid)
gen beta2=_b[post2012_provincecount]
* Row 1 Column 3
gen diff1_2=beta1/(beta2-beta1)
drop beta*
sum diff*
drop diff*


local demographics "male age eduyear urban han partymember"
local provincefe "i.provinceid"

*Full 6*
xi:reg supportcenter post2012_provincecount post2012 provincecount `demographics' `provincefe', cl(provinceid)
gen beta3=_b[post2012_provincecount]
* Restricted #6
xi:reg supportcenter post2012_provincecount post2012 provincecount `provincefe', cl(provinceid)
gen beta4=_b[post2012_provincecount]
* Row 2 Column 3
gen diff3_4=beta3/(beta4-beta3)
drop beta*
sum diff*
drop diff*


*support central party*

local demographics "male age eduyear urban han partymember"
local provincefe "i.provinceid"

*Full 7*
xi:reg supportcentralparty post2012_provincecount post2012 provincecount `provincefe', cl(provinceid)
gen beta1=_b[post2012_provincecount]
* Restricted #7
xi:reg supportcentralparty post2012_provincecount post2012 provincecount, cl(provinceid)
gen beta2=_b[post2012_provincecount]
* Row 1 Column 4
gen diff1_2=beta1/(beta2-beta1)
drop beta*
sum diff*
drop diff*


local demographics "male age eduyear urban han partymember"
local provincefe "i.provinceid"

*Full 8*
xi:reg supportcentralparty post2012_provincecount post2012 provincecount `demographics' `provincefe', cl(provinceid)
gen beta3=_b[post2012_provincecount]
* Restricted #8
xi:reg supportcentralparty post2012_provincecount post2012 provincecount `provincefe', cl(provinceid)
gen beta4=_b[post2012_provincecount]
* Row 2 Column 4
gen diff3_4=beta3/(beta4-beta3)
drop beta*
sum diff*
drop diff*
	

************************************
*Table A3.15: Using Wild Bootstrap Standard Errors*
************************************

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

xi: reg supportcentralparty post2012_provincecount post2012 provincecount
estimates store wildbootmodel1
estadd ysumm

boottest post2012_provincecount,boot(wild)

xi: reg supportcentralparty post2012_provincecount post2012 i.provinceid
estimates store wildbootmodel2
estadd ysumm

boottest post2012_provincecount,boot(wild)

xi: reg supportcentralparty post2012_provincecount post2012 `demographics' i.provinceid
estimates store wildbootmodel3
estadd ysumm

boottest post2012_provincecount,boot(wild)

*Manually put Wild Bootstrap Confidence Intervals into the following table*

esttab wildbootmodel1 wildbootmodel2 wildbootmodel3 using table_a_3_15.csv, replace ///
    keep(post2012_provincecount post2012) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = _Iprovincei_*")
	

	
************************************
*Table A3.16: Using a Dichotomous Independent Variable (Above Mean Number of Corruption Investigations)*
************************************

*Dichotomize provinces by their number of investigations: treat=1 if no. of investigations>national mean, otherwise 0*

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount_treat post2012 provincecount_treat
estimates store dichotomousmodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount_treat post2012 i.new_pid
estimates store dichotomousmodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount_treat post2012 `demographics' i.new_pid
estimates store dichotomousmodel3
estadd ysumm

esttab dichotomousmodel1 dichotomousmodel2 dichotomousmodel3 using table_a_3_16.csv, replace ///
    keep(post2012_provincecount_treat post2012 provincecount_treat) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *new_pid*")



************************************
*Table A3.17: Interacting with Provinces That Have Connections with Xi Jinping*
************************************
*According to Jiang et al. (BJPS), Xi has either served as senior provincial leader or had strong family connections in Zhejiang, Fujian, Shanghai, and Shaanxi.

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(newer_pid) noi: reg supportcentralparty post2012_provincecount_xiprov post2012_xiprov post2012_provincecount provincecount_xiprov post2012 provincecount xiprovince

estimates store xidummymodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(newer_pid) noi: reg supportcentralparty post2012_provincecount_xiprov post2012_xiprov post2012_provincecount provincecount_xiprov post2012 i.newer_pid
estimates store xidummymodel2 
estadd ysumm

bootstrap, cluster(provinceid) idcluster(newer_pid) noi: reg supportcentralparty post2012_provincecount_xiprov post2012_xiprov post2012_provincecount provincecount_xiprov post2012 `demographics' i.newer_pid
estimates store xidummymodel3
estadd ysumm

esttab xidummymodel1 xidummymodel2 xidummymodel3 using table_a_3_17.csv, replace ///
    keep(post2012_provincecount_xiprov post2012_xiprov post2012_provincecount provincecount_xiprov post2012 provincecount xiprovince) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *newer_pid*")

	
************************************
*Table A3.18: Dropping Provinces That Have Connections with Xi Jinping*
************************************

*According to Jiang et al. (BJPS), Xi has either served as senior provincial leader or had strong family connections in Zhejiang, Fujian, Shanghai, and Shaanxi.

use "WandDicksonPSRMMainData.dta", clear

drop if provinceid==350000 | provinceid==310000 | provinceid==330000 | provinceid==610000

save "WandDicksonPSRMMainData_DropXiProv.dta", replace

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(newest_pid) noi: reg supportcentralparty post2012_provincecount post2012 provincecount

estimates store noxiprovincemodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(newest_pid) noi: reg supportcentralparty post2012_provincecount post2012 i.newest_pid
estimates store noxiprovincemodel2 
estadd ysumm

bootstrap, cluster(provinceid) idcluster(newest_pid) noi: reg supportcentralparty post2012_provincecount post2012 `demographics' i.newest_pid
estimates store noxiprovincemodel3
estadd ysumm

esttab noxiprovincemodel1 noxiprovincemodel2 noxiprovincemodel3 using table_a_3_18.csv, replace ///
    keep(post2012_provincecount post2012 provincecount) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *newest_pid*")

	

************************************
*Table A3.19: Using Number of Corruption Investigations (Weighted by Time)*
************************************

*A time discount rate of 0.9*
*So investigations that happened in 2013 are discounted by 0.9*
*investigations that happened in 2012 are discounted by 0.9^2*
*investigations that happened in 2011 are discounted by 0.9^3*

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount_t post2012 provincecount_timediscount
estimates store timemodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount_t post2012 i.new_pid
estimates store timemodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount_t post2012 `demographics' i.new_pid
estimates store timemodel3
estadd ysumm

esttab timemodel1 timemodel2 timemodel3 using table_a_3_19.csv, replace ///
    keep(post2012_provincecount_t post2012 provincecount_timediscount) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *new_pid*")


************************************
*Table A3.20: Quadratic Term of Number of Corruption Investigations*
************************************

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(newer_pid) noi: reg supportcentralparty post2012_provincecount_sq post2012_provincecount provincecount_sq post2012 provincecount

estimates store quadraticmodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(newer_pid) noi: reg supportcentralparty post2012_provincecount_sq post2012_provincecount post2012 i.newer_pid
estimates store quadraticmodel2 
estadd ysumm

bootstrap, cluster(provinceid) idcluster(newer_pid) noi: reg supportcentralparty post2012_provincecount_sq post2012_provincecount post2012 `demographics' i.newer_pid
estimates store quadraticmodel3
estadd ysumm

esttab quadraticmodel1 quadraticmodel2 quadraticmodel3 using table_a_3_20.csv, replace ///
    keep(post2012_provincecount_sq post2012_provincecount provincecount_sq post2012 provincecount) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *newer_pid*")


************************************
*Figure A3.1: Placebo Tests with 100 Hypothetical Campaigns*
************************************

*Use the following code to generate 100 trials

use "WandDicksonPSRMMainData.dta", clear

keep provinceid
bysort provinceid: gen count=_n 
keep if count==1

drop count

*generate a random number from uniform distribution and mutiply it by 366 -- the maximum N of investigations in the sample*

set seed 339487731

forvalues i=1(1)100 { 
generate rannum`i' = uniform()
gen provincecount`i'=366*rannum`i' 
}  


forvalues i=1(1)100 { 
drop rannum`i'
} 

save "randomnumber.dta",replace

use "WandDicksonPSRMMainData.dta"

merge m:1 provinceid using "randomnumber.dta"

drop _merge

forvalues i=1(1)100 { 
gen post2012_provincecount`i'=post2012*provincecount`i'
} 

save "placebo.dta", replace

*Estimates*

use "placebo.dta", clear

set seed 339487731

forvalues i=1(1)100 { 
quietly bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty post2012_provincecount`i' post2012 i.new_pid
        parmest, le(95) sa("placebo_`i'.dta", replace)
} 


forvalues i = 1(1)100 {
	use "placebo_`i'.dta", clear
	gen N=_n
	keep if N==1
	gen trialno="`i'"
	keep parm estimate min95 max95 trialno
	save, replace
}

use "placebo_1.dta", clear
forvalues i = 1(1)100 {
	append using "placebo_`i'.dta"
	}
drop in 1
save "placeboestimates.dta", replace

sort estimate
gen trial=_n
save, replace

*Making the graph*

use "placeboestimates.dta", clear

twoway (rcap min95 max95 trial, vertical msize(vtiny)) ///
	(scatter estimate trial, msymbol(circle) mcolor(black) msize(small)) ///
	, scheme(sj) graphregion(fcolor(white)) ///
	legend(off) ///
	xscale(range(0 100)) xlabel(0(10)100,angle(0) valuelabel labsize(small)) xtitle("Trial Number") ///
	yline(0, lpattern(dash)) ///
	yscale(range(-0.006 0.006)) ylabel(-0.006(0.002)0.006, labsize(small)) ytitle("Treatment Effect of Corruption Investigations") ///
    legend(off) 
graph export figure_a_3_1.pdf, as(pdf) replace

clear


*********
*Figure A3.2: Dropping One Province at a Time*
*********

*Use the following code to drop one province a time and obtain the estimates

*use "WandDicksonPSRMMainData.dta",clear

*egen id=group(provinceid) 

*forvalues i=1(1)25 { 
*	quietly xi: reg supportcentralparty post2012_provincecount post2012 i.provinceid if id~=`i'
*	parmest, le(95) sa("province_`i'.dta", replace)
*}  

*forvalues i = 1(1)25 {
*	use "province_`i'.dta", clear
*	gen N=_n
*	keep if N==1
*	gen provinceno="`i'"
*	keep parm estimate min95 max95 provinceno
*	save, replace
*}

*use "province_1.dta", clear
*forvalues i = 1(1)25 {
*	append using "province_`i'.dta"
*	}
*drop in 1
*save "dropprovince.dta", replace

*encode provinceno, gen(province)
*sort province
*save, replace

*Making the graph*

use "dropprovince.dta", clear

label define xaxis 1 "Beijing" 2 "Tianjin" 3 "Hebei" ///
4 "Shanxi" 5 "Liaoning" 6 "Jilin" 7 "Heilongjiang" 8 "Shanghai" ///
9 "Jiangsu" 10 "Zhejiang" 11 "Anhui" 12 "Fujian" 13 "Jiangxi" 14 "Shandong" ///
15 "Henan" 16 "Hubei" 17 "Hunan" 18 "Guangdong" 19 "Guangxi" 20 "Chongqing" ///
21 "Sichuan" 22 "Yunnan" 23 "Shaanxi" 24 "Gansu" 25 "Qinghai"

label values province xaxis

twoway (rcap min95 max95 province, vertical msize(vtiny)) ///
	(scatter estimate province, msymbol(cirlce) mcolor(black) msize(small)) ///
	, scheme(sj) graphregion(fcolor(white))  ///
	legend(off) ///
	xscale(range(1 25)) xlabel(1(1)25,angle(45) valuelabel labsize(small)) xtitle("Excluded Province") ///
	yline(0, lpattern(dash)) ///
	yscale(range(-0.003 0)) ylabel(-0.003(0.001)0, labsize(small)) ytitle("Treatment Effect of Corruption Investigations") ///
    legend(off) 
graph export figure_a_3_2.pdf, as(pdf) replace


************************************************************************
*Section IV: Evidence on Updating*
************************************************************************


************************************
*Table A4.1: OLS Estimates of the Effects of Beliefs in Officials’ Integrity on Support for Central Party*
************************************

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty officialhonest
estimates store beliefmodel1
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty officialhonest i.new_pid
estimates store beliefmodel2
estadd ysumm

bootstrap, cluster(provinceid) idcluster(new_pid) noi: reg supportcentralparty officialhonest `demographics' i.new_pid
estimates store beliefmodel3
estadd ysumm

esttab beliefmodel1 beliefmodel2 beliefmodel3 using table_a_4_1.csv, replace ///
    keep(officialhonest) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *new_pid*")
	

************************************
*Table A4.2: Estimates of the Marginal Effect of Corruption Investigations in Different Levels of Prior Beliefs in Officials’ Integrity (Using Stata’s interflex Package)*
************************************

use "WandDicksonPSRMMainData.dta", clear

interflex supportcentralparty post2012_provincecount priorofficialhonest _Iprovincei_120000-_Iprovincei_630000 male age eduyear urban han partymember, cl(provinceid) cut(2.4 2.7)  ylabel(Support for Central Party) dlabel(Corruption Investigations) xlabel(Prior Beliefs in Officials' Integrity)

return list
mat list r(estBin)

*To get the bootstrap S.E.*

set seed 339487731
interflex supportcentralparty post2012_provincecount priorofficialhonest _Iprovincei_120000-_Iprovincei_630000 male age eduyear urban han partymember, vce(boot)  cut(2.4 2.7)  ylabel(Support for Central Party) dlabel(Corruption Investigations) xlabel(Prior Beliefs in Officials' Integrity) sav(interactfig1boot.gph)

return list
mat list r(estBin)


************************************
*Table A4.3: Causal Mediation Analysis (Treatment: N of Corruption Investigations; Mediator: Beliefs in Officials’ Integrity; Outcome: Support for Central Party)*
************************************	

use "WandDicksonPSRMMainData.dta", clear

medeff (regress officialhonest post2012_provincecount male age eduyear urban han partymember post2012 _Iprovincei_130000-_Iprovincei_630000) (regress supportcentralparty officialhonest post2012_provincecount male age eduyear urban han partymember post2012 _Iprovincei_130000-_Iprovincei_630000), mediate(officialhonest) treat(post2012_provincecount) vce(robust) level(95)


************************************************************************
*Section V: Evidence on Social Media Consumption*
************************************************************************


************************************
*Table A5.1: OLS Estimates of the Effect of Corruption Investigations on Social Media News Consumption*
************************************

use "WandDicksonPSRMMainData.dta", clear

local demographics "male age eduyear urban han partymember"
set seed 339487731

bootstrap, cluster(provinceid) idcluster(new_pid) noi:reg socialmedia provincecount `demographics' i.new_pid
estimates store socialmediamodel
estadd ysumm

esttab socialmediamodel using table_a_5_1.csv, replace ///
    keep(provincecount) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) ///
	label noconstant   ///
	stats(ymean ysd N N_clust r2, fmt(3 3 0 0 3) labels("Outcome Mean" "Outcome S.D." "Observations" "N of Clusters" "R2")) ///
	indicate("Demographic Controls = male" "Province FE = *new_pid*")

	
************************************
*Table A5.2: Estimates of the Marginal Effect of Corruption Investigations in Different Levels of Social Media News Consumption (Using Stata’s interflex Package)*
************************************

use "WandDicksonPSRMMainData.dta", clear

interflex supportcentralparty post2012_provincecount socialmedia_pro _Iprovincei_120000-_Iprovincei_630000 male age eduyear urban han partymember, cut(0.05 0.2 0.35) cl(provinceid) ylabel(Support for Central Party) dlabel(Corruption Investigations) xlabel(Social Media News Consumption) 

return list
mat list r(estBin)

*To get the bootstrap S.E.*

set seed 339487731
interflex supportcentralparty post2012_provincecount socialmedia_pro _Iprovincei_120000-_Iprovincei_630000 male age eduyear urban han partymember, cut(0.05 0.2 0.35) vce(boot) ylabel(Support for Central Party) dlabel(Corruption Investigations) xlabel(Social Media News Consumption)

return list
mat list r(estBin)


************************************
*Figure A5.1: Scatterplot of Prior Beliefs in Officials’ Integrity and Social Media News Consumption*
************************************

use "SocialMediaAndPrior.dta", clear

*Correlation coefficient*
pwcorr priorofficialhonest socialmedia,sig

*Scatter plot*

twoway (scatter priorofficialhonest socialmedia, mcolor(black) mlabel(provincename)) ///
(lfit priorofficialhonest socialmedia, lpattern(solid) lcolor(black) lwidth(medthick) ),  ///
legend(off) xlab(0(0.1)0.5)  ytitle("Prior Beliefs in Officials' Integrity") xtitle("Social Media News Consumption") ///
scheme(sj)  scale(0.8)  graphregion(fcolor(white)) text(1.9 0.2 "slope = 0.05, p=0.81", place(se) size(vlarge))

graph export "figure_a_5_1.pdf", as(pdf) name("Graph")

************************************
*Figure A5.2: Marginal Effect of Corruption Investigations at Different Levels of Social Media News Consumption*
************************************

use "WandDicksonPSRMMainData.dta", clear

interflex supportcentralparty post2012_provincecount socialmedia_pro _Iprovincei_120000-_Iprovincei_630000 male age eduyear urban han partymember, cut(0.05 0.2 0.35) cl(provinceid) ylabel(Support for Central Party) dlabel(Corruption Investigations) xlabel(Social Media News Consumption) sav(figure_a_5_2.gph)

*NOTE: Hainmueller, Mummolo, and Xu (2019) argues that a linear interaction effect often produces excessive extrapolation and suggest a more flexible estimation strategy based on binned estimates. We hence only show the binned estimates and manually remove the linear extrapolation in the graph. This is done by clicking the "Graph Editor" in the Stata graph window. You can also change the aethetics of the graph. 

clear

********************************************************************************
*THE END*
********************************************************************************

log close WangDickson2021PSRM

exit


